﻿using MediatR;
using MyMES.Domain.zyy;
using MyMES.Error;
using MyMES.Infrastructure.Interface;
using MyMES.Read.API.Application.Commends.Productionorderss;

namespace MyMES.Read.API.Application.CommendHandlers.Productionorderss
{
    public class GetProductionorderssWorkCommendHandlers : IRequestHandler<GetProductionorderssWorkCommends, APIPaging<List<WorkOrder>>>
    {
        private readonly IBaseRepository<WorkOrder> repository;

        public GetProductionorderssWorkCommendHandlers(IBaseRepository<WorkOrder> repository)
        {
            this.repository = repository;
        }

        /// <summary>
        /// 获取生产信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<APIPaging<List<WorkOrder>>> Handle(GetProductionorderssWorkCommends request, CancellationToken cancellationToken)
        {
            APIPaging<List<WorkOrder>> result = new APIPaging<List<WorkOrder>>();
            result.Code = APIEnum.查询成功;
            result.Msg = "显示成功";
            string sql = "select *  from WorkOrder where IsDlete=false ORDER BY WorkOrderId  DESC";
            var list = await repository.SelectAsync(sql);
            result.data = list;
            return result;
        }
    }
}
